{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/caserecord/index.css" />
    <style>

    </style>
{/block}

{block name="page_section"}

    <div class="sessionPage">
      <ul class="nav nav-tabs" style="width: 95%; margin:10px auto;">
          <li {if $type == 1} class="active"{/if}><a href="/smslog/index?type=1" style="color:#1D2129;font-size: 15px"><b>发送记录</b></a></li>
          <li {if $type == 2} class="active"{/if}><a href="/smslog/index?type=2" style="color:#1D2129;font-size: 15px"><b>回复记录</b></a></li>
      </ul>
      <form class="small-style" method="get" action="" role="validform"enctype="multipart/form-data">
      {if $query['type']==1}
        <div class="form_row">
          <input type="hidden"   value="{if !empty($query.type)}{$query.type}{/if}" name="type" id="type" >
          <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
            <input type="hidden" name="is_show" class="showmoreishow" value="{if $is_show == 1}1{else}0{/if}">
            <div class="form-group col-lg-3 ui-select" style="margin-top:10px;">
              <label for="exampleInputName2"  class="col-sm-4 control-label">发送部门:</label>
              <div class="col-sm-7">
                  <select class="form-control" name="mediationOrganId">
                      <option class="u144_input_option"  {if $query.mediationOrganId=='0'}selected="selected"{/if} value="0">全部</option>
                      {foreach from=$mediationOrganList item=item key=key}
                          <option class="u144_input_option" {if $query.mediationOrganId==$key}selected="selected"{/if} value="{$key}">{$item.name}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
            <div class="form-group col-lg-3 ui-select" style="margin-top:10px;">
                <label for="exampleInputName2"  class="col-sm-4 control-label">案件归属部门:</label>
                <div class="col-sm-7">
                    <select class="form-control" name="caseMediationOrganId">
                        <option class="u144_input_option"  {if $query.caseMediationOrganId=='0'}selected="selected"{/if} value="0">全部</option>
                        {foreach from=$mediationOrganList item=item key=key}
                        <option class="u144_input_option" {if $query.caseMediationOrganId==$key}selected="selected"{/if} value="{$key}">{$item.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">资产方:</label>
                <div class="col-sm-7">
                    <select class="form-control selectpicker"   title="请选择" name="assetsId" id="assetsId">
                        {foreach from=$assets  item=info}
                        <option class="u144_input_option" {if !empty($query.assetsId) &&  $info.id == $query.assetsId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">场景:</label>
                <div class="col-sm-7">
                    <select class="form-control" name="scene" role-ele="scene">
                        <option value="0" selected="selected">全部</option>
                        {foreach from=$scene key=key item=item}
                            <option value="{$key}" {if $query.scene == $key} selected="selected" {/if}>{$item}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
        <div class="form_row">
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">接受状态:</label>
                <div class="col-sm-7">
                    <select class="form-control" name="sendStatus" role-ele="sendStatus">
                        <option value="0" selected="selected">全部</option>
                        <option value="1" {if $query.sendStatus == 1} selected="selected" {/if}>接受成功</option>
                        <option value="2" {if $query.sendStatus == 2} selected="selected" {/if}>发送中</option>
                        <option value="3" {if $query.sendStatus == 3} selected="selected" {/if}>提交失败</option>
                        <option value="4" {if $query.sendStatus == 4} selected="selected" {/if}>接受失败</option>
                        <option value="5" {if $query.sendStatus == 5} selected="selected" {/if}>接受未知</option>

                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">提交人:</label>
                <div class="col-sm-7">
                    <select class="form-control" id="is_contrast" name="mediatorId">
                        <option class="u144_input_option" {if $query.mediatorId==0}selected="selected"{/if} value="0">全部</option>
                        {foreach from=$mediator item=item }
                        {if $item.id != 1}
                        <option class="u144_input_option" {if $query.mediatorId == $item.id}selected="selected"{/if} value="{$item.id}">{$item.name}</option>
                        {/if}
                        {/foreach}
                    </select>
                </div>
            </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
              </div>
          </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">手机号:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.mobile)}{$query.mobile}{/if}" name="mobile" id="mobile" placeholder="请输入~">
                </div>
            </div>

        </div>
          <div class="form_row start-hide col-lg-12" data-isshow="{if $is_show == 1}true{else}false{/if}" {if $is_show == 1}style="padding:0px;"{else}style="padding:0px;display:none;"{/if}>
              <div class="form-group col-lg-3 ui-select">
                  <label for="startTime" class="col-sm-4 control-label">{if $query.type==1}发送时间{else}回复时间{/if}:</label>
                  <div class="col-sm-7">
                      <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
                  </div>
              </div>
              <div class="form-group col-lg-3 ui-select">
                  <label for="exampleInputName2"  class="col-sm-4 control-label">案件号:</label>
                  <div class="col-sm-7">
                      <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.caseId)}{$query.caseId}{/if}" name="caseId" id="caseId" placeholder="请输入~">
                  </div>
              </div>
              <div class="form-group col-lg-3 ui-select">
                  <label for="exampleInputName2"  class="col-sm-4 control-label">导入批次ID:</label>
                  <div class="col-sm-7">
                      <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.importRecordId)}{$query.importRecordId}{/if}" name="importRecordId" id="importRecordId" placeholder="请输入~">
                  </div>
              </div>
              <div class="form-group col-lg-3 ui-select">
                  <label for="exampleInputName2"  class="col-sm-4 control-label">案件标识号:</label>
                  <div class="col-sm-7">
                      <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batshId)}{$query.batshId}{/if}" name="batshId" id="batshId" placeholder="请输入~">
                  </div>
              </div>

        </div>
          <div class="form_row col-lg-12" style="padding:0px;">
              <div class="form-group col-lg-3 ui-select">
                  <div class="col-lg-5" >
                      <button class="btn btn-primary col-lg-8 shousuoBtn"> <span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
                  </div>

                  <div class="col-lg-5">
                      <a type="button" {if $query.type==1}href="/smslog/index"{else}href="/smslog/index?type=2"{/if} class="btn btn-default col-lg-8" ><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
                  </div>
                  <div class="col-lg-5">
                      <a style="width:auto;" type="button" href="javascript:;" class="btn btn-default col-lg-8 show-more-btn">》更多</a>
                  </div>
              </div>
              <div class="ui-select"></div>
              <div class="ui-select"></div>
              <div class="ui-select"></div>
          </div>
      {/if}
      {if $query['type']!=1}
        <div class="form_row">
          <input type="hidden"   value="{if !empty($query.type)}{$query.type}{/if}" name="type" id="type" >
          <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
          <div class="form-group col-lg-3 ui-select" style="margin-top:10px;">
              <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
              <div class="col-sm-7">
                  <select class="form-control" name="mediationOrganId">
                      <option class="u144_input_option"  {if $query.mediationOrganId=='0'}selected="selected"{/if} value="0">全部</option>
                      {foreach from=$mediationOrganList item=item key=key}
                          <option class="u144_input_option" {if $query.mediationOrganId==$key}selected="selected"{/if} value="{$key}">{$item.name}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">手机号:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.mobile)}{$query.mobile}{/if}" name="mobile" id="mobile" placeholder="请输入~">
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
            <label for="startTime" class="col-sm-4 control-label">{if $query.type==1}发送时间{else}回复时间{/if}:</label>
            <div class="col-sm-7">
                <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
            </div>
          </div>
        </div>
        <div class="form_row">
          <div class="form-group col-lg-3 ui-select">
              <div class="col-lg-4" >
                  <button class="btn btn-primary col-lg-8 shousuoBtn"> <span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
              </div>
              <div class="col-lg-4">
                  <a type="button" {if $query.type==1}href="/smslog/index"{else}href="/smslog/index?type=2"{/if} class="btn btn-default col-lg-8" ><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
              </div>
          </div>
          <div class="ui-select"></div>
          <div class="ui-select"></div>
          <div class="ui-select"></div>
        </div>
      {/if}
      </form >
      <div style="width: 95%;
          margin: 0 auto;
          display: flex;
          flex-direction: column;
          overflow-x: scroll;">
        <table class="table table-striped table-bordered table-hover" id="tab">
                {if $query.type==1}
                        <thead>
                        <tr>
                            <th>调解部门</th>
                            <th>提交人</th>
                            <th>案件号</th>
                            <th>场景</th>
                            <th>发送时间</th>
                            <th>手机号</th>
                            <th>接受状态</th>
                            <th>原因</th>
                            <th>签名</th>
                            <th width="30%">内容</th>
                        </tr>
                        </thead>
                        <tbody>
                        {if $arrList}
                            {foreach from=$arrList item=info}
                                <tr>
                                    <td>{$mediationOrganList[$info['mediationOrganId']]['name']}</td>
                                    <td>{$info['mediator']}</td>
                                    <td>{if {$info['caseId']}}{$info['caseId']}{else}-{/if}</td>
                                    <td>
                                        {$scene[$info['scene']]}
                                    </td>
                                    <td>{$info['sendTime']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                                    <td>
                                        {substr($info.mobile,0,3)}****{substr($info.mobile,7,4)}
                                    </td>
                                    <td>
                                        {if $info['sendStatus'] == 1}
                                            接受成功
                                        {elseif $info['sendStatus'] == 2}
                                            发送中
                                        {elseif $info['sendStatus'] == 3}
                                            提交失败
                                        {elseif $info['sendStatus'] == 4}
                                            接受失败
                                        {elseif $info['sendStatus'] == 5}
                                            接受未知
                                        {/if}
                                    </td>
                                    <td>
                                        {$info['sendResult']}
                                    </td>
                                    <td>
                                        {$info['sign']}
                                    </td>
                                    <td>
                                        <a href="#" style="text-decoration: none;color: inherit;" class="tooltip-test" data-toggle="tooltip" data-placement="bottom" title="{$info.content}">
                                            {if mb_strlen($info.content) > 80}
                                                {mb_substr($info.content,0,80,'UTF-8')}...
                                            {else}
                                                {$info.content}
                                            {/if}
                                        </a>

                                    </td>
                                </tr>
                            {/foreach}
                        {/if}
                        </tbody>
                {else}
                    <thead>
                    <tr>
                        <th>调解部门</th>
                        <th>调解员名字</th>
                        <th>案件号</th>
                        <th>内容</th>
                        <th>回复时间</th>
                        <th>回复手机号</th>
                        <th width="30%">回复短信</th>
                    </tr>
                    </thead>
                    <tbody>
                    {if $arrList}
                        {foreach from=$arrList item=info}
                            <tr>
                                <td>{$mediationOrganList[$info['mediationOrganId']]['name']}</td>
                                <td>{$info['mediator']}</td>
                                <td>{$info['caseId']}</td>
                                <td>{$info['content']}</td>
                                <td>{$info['replyTime']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                                <td>
                                    {substr($info.mobile,0,3)}****{substr($info.mobile,7,4)}
                                </td>
                                <td>
                                    <a href="#" style="text-decoration: none;color: inherit;" class="tooltip-test" data-toggle="tooltip" data-placement="bottom" title="{$info.smsRecordContent}">
                                        {if mb_strlen($info.smsRecordContent) > 80}
                                            {mb_substr($info.smsRecordContent,0,80,'UTF-8')}...
                                        {else}
                                            {$info.smsRecordContent}
                                        {/if}
                                    </a>
                                </td>
                            </tr>
                        {/foreach}
                    {/if}
                    </tbody>
                {/if}


            </table>
      </div>
    <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
        {include file="base/pagenav.html" action="/smslog/index" pagenum=$curPageNum inline}
        <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
            <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
            <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
            <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
            <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
        </select>
        {if $query.type==1}
        <span style="float:right;">计费条数 {$billableNum} 条，提交 {$totalnum} 条</span>
        {else}
        <span style="float:right;">共 {$totalnum} 条</span>

        {/if}
    </div>


    </div>
{/block}
{block name="page_scripts"}


    <script type="text/javascript">

        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        $('body').on('change','#paglimit', function(){
            console.log()
            var mediationOrganId = GetQueryString('mediationOrganId');
            var type = GetQueryString('type');
            var paglimit = GetQueryString('limit');
            var val =  $(this).val();

            if(!mediationOrganId){
               if(!paglimit && type){
                    window.location = window.location.href+'&'+val;
                }else if(!paglimit){
                    window.location = window.location.href+'?'+val;
                }else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
        })

    </script>
{/block}
